package org.jground.rx.def.apps.ipm;
import org.jground.rx.*;
import org.jground.rx.gen.*;
import org.jground.util.*;
import java.util.List;
import org.jground.rx.def.apps.accounting.*;
import org.jground.rx.def.apps.commons.*;
import org.jground.rx.def.apps.knowledge.*;
import org.jground.rx.def.*;
import org.jground.rx.def.apps.crm.*;
import org.jground.rx.def.apps.cip.*;
import org.jground.rx.def.apps.core.*;
import org.jground.rx.def.apps.legal.*;
@SuppressWarnings("unused")
public class Contract extends GenRoot {

    public static final String moid = "org.jground.rx.def.apps.ipm.Contract";

    private static final String title ="title";
    private static final String contractNumber ="contractNumber";
    private static final String contractDate ="contractDate";
    private static final String products ="products";
    private static final String counterParty ="counterParty";
    private static final String contactInformation ="contactInformation";
    private static final String contractAddress ="contractAddress";
    private static final String contractDuration ="contractDuration";
    private static final String earlyTermination ="earlyTermination";
    private static final String applicableLaw ="applicableLaw";
    private static final String placeOfJuristiction ="placeOfJuristiction";
    private static final String contractStatus ="contractStatus";
    private static final String documents ="documents";
    private static final String $CREATOR ="$CREATOR";

    public static final class AttName {
        public static final String title ="title";
        public static final String contractNumber ="contractNumber";
        public static final String contractDate ="contractDate";
        public static final String products ="products";
        public static final String counterParty ="counterParty";
        public static final String contactInformation ="contactInformation";
        public static final String contractAddress ="contractAddress";
        public static final String contractDuration ="contractDuration";
        public static final String earlyTermination ="earlyTermination";
        public static final String applicableLaw ="applicableLaw";
        public static final String placeOfJuristiction ="placeOfJuristiction";
        public static final String contractStatus ="contractStatus";
        public static final String documents ="documents";
        public static final String $CREATOR ="$CREATOR";
    }

    public static Contract createNew() { return new Contract(RXObjectService.getInstance().create(moid)); }

    public static Contract getById(String oid) { 
        IRXObject mod = RXObjectService.getInstance().getById(oid);
        if(mod == null) { return null; }
        return new Contract(mod);
    }

    public static Contract[] getByIds(String... oids) { 
        List<IRXObject> mods = RXObjectService.getInstance().getByIds(moid, oids);
        Contract[] res = new Contract[mods.size()];
        int i = 0;
        for(IRXObject mod : mods) {
            res[i] = new Contract(mod);
            i++;
        }
        return res;
    }

    public static SearchCriteria newSearchCriteria() {
        return  SearchCriteria.create(moid);
    }

    public static Contract[] search(SearchCriteria sc) {
        return  wrap(GenRoot._search(sc));
    }

    public static Contract[] wrap(List<? extends IRXObjectSynopsis> mods) { 
        Contract[] res = new Contract[mods.size()];
        int i = 0;
        for(IRXObjectSynopsis mod : mods) {
            res[i] = new Contract(mod);
            i++;
        }
        return res;
    }

    public static Contract wrap(IRXObjectSynopsis mod) { 
        return new Contract(mod);
    }

    private Contract(IRXObjectSynopsis rxObject) {this.rxObject = (IRXObject) rxObject;}

    public static String getTitleLabel() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, title).getLabel();
    }

    public static String getTitleDescription() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, title).getDescription();
    }

    public void setTitle(String string) {
        rxObject.set(title, _to_String(string));
    }

    public String getTitle() {
        return _to_String(rxObject.getCurrentValue(title));
    }

    public static String getContractNumberLabel() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, contractNumber).getLabel();
    }

    public static String getContractNumberDescription() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, contractNumber).getDescription();
    }

    public void setContractNumber(String string) {
        rxObject.set(contractNumber, _to_String(string));
    }

    public String getContractNumber() {
        return _to_String(rxObject.getCurrentValue(contractNumber));
    }

    public static String getContractDateLabel() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, contractDate).getLabel();
    }

    public static String getContractDateDescription() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, contractDate).getDescription();
    }

    public void setContractDate(String dateValue) {
        rxObject.set(contractDate, _to_String(dateValue));
    }

    public String getContractDate() {
        return _to_String(rxObject.getCurrentValue(contractDate));
    }

    public static String getProductsLabel() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, products).getLabel();
    }

    public static String getProductsDescription() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, products).getDescription();
    }

    public void addProducts(org.jground.rx.def.apps.cip.Product... value) {
        rxObject.set(products, _to_String(value));
    }

    public void setProducts(org.jground.rx.def.apps.cip.Product[] values) {
        rxObject.set(products, _to_String(values));
    }

    public int getProductsSize() {
        return StringUtils.rnn(rxObject.getValues(products)).length;
    }

    public org.jground.rx.def.apps.cip.Product[] getProducts() {
        return org.jground.rx.def.apps.cip.Product.getByIds(rxObject.getValues(products));
    }

    public org.jground.rx.def.apps.cip.Product getProducts(int index) {
        return org.jground.rx.def.apps.cip.Product.getByIds(rxObject.getValues(products))[index];
    }

    public static String getCounterPartyLabel() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, counterParty).getLabel();
    }

    public static String getCounterPartyDescription() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, counterParty).getDescription();
    }

    public void addCounterParty(org.jground.rx.def.apps.core.LegalEntity... value) {
        rxObject.set(counterParty, _to_String(value));
    }

    public void setCounterParty(org.jground.rx.def.apps.core.LegalEntity[] values) {
        rxObject.set(counterParty, _to_String(values));
    }

    public int getCounterPartySize() {
        return StringUtils.rnn(rxObject.getValues(counterParty)).length;
    }

    public org.jground.rx.def.apps.core.LegalEntity[] getCounterParty() {
        return org.jground.rx.def.apps.core.LegalEntity.getByIds(rxObject.getValues(counterParty));
    }

    public org.jground.rx.def.apps.core.LegalEntity getCounterParty(int index) {
        return org.jground.rx.def.apps.core.LegalEntity.getByIds(rxObject.getValues(counterParty))[index];
    }

    public static String getContactInformationLabel() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, contactInformation).getLabel();
    }

    public static String getContactInformationDescription() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, contactInformation).getDescription();
    }

    public void setContactInformation(String text) {
        rxObject.set(contactInformation, _to_String(text));
    }

    public String getContactInformation() {
        return _to_String(rxObject.getCurrentValue(contactInformation));
    }

    public static String getContractAddressLabel() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, contractAddress).getLabel();
    }

    public static String getContractAddressDescription() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, contractAddress).getDescription();
    }

    public org.jground.rx.def.apps.core.Address getContractAddress() {
        return ArrayUtils.first(org.jground.rx.def.apps.core.Address.wrap(rxObject.getComponents(AttName.contractAddress)));
    }

    public org.jground.rx.def.apps.core.Address createContractAddress() {
        return org.jground.rx.def.apps.core.Address.wrap(rxObject.newComponent(contractAddress));
    }

    public void setContractAddress(org.jground.rx.def.apps.core.Address value) {
        rxObject.set(contractAddress, value.getOidString());
    }

    public static String getContractDurationLabel() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, contractDuration).getLabel();
    }

    public static String getContractDurationDescription() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, contractDuration).getDescription();
    }

    public void setContractDuration(String dateValue) {
        rxObject.set(contractDuration, _to_String(dateValue));
    }

    public String getContractDuration() {
        return _to_String(rxObject.getCurrentValue(contractDuration));
    }

    public static String getEarlyTerminationLabel() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, earlyTermination).getLabel();
    }

    public static String getEarlyTerminationDescription() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, earlyTermination).getDescription();
    }

    public void setEarlyTermination(String text) {
        rxObject.set(earlyTermination, _to_String(text));
    }

    public String getEarlyTermination() {
        return _to_String(rxObject.getCurrentValue(earlyTermination));
    }

    public static String getApplicableLawLabel() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, applicableLaw).getLabel();
    }

    public static String getApplicableLawDescription() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, applicableLaw).getDescription();
    }

    public void setApplicableLaw(String string) {
        rxObject.set(applicableLaw, _to_String(string));
    }

    public String getApplicableLaw() {
        return _to_String(rxObject.getCurrentValue(applicableLaw));
    }

    public static String getPlaceOfJuristictionLabel() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, placeOfJuristiction).getLabel();
    }

    public static String getPlaceOfJuristictionDescription() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, placeOfJuristiction).getDescription();
    }

    public void setPlaceOfJuristiction(String string) {
        rxObject.set(placeOfJuristiction, _to_String(string));
    }

    public String getPlaceOfJuristiction() {
        return _to_String(rxObject.getCurrentValue(placeOfJuristiction));
    }

    public static String getContractStatusLabel() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, contractStatus).getLabel();
    }

    public static String getContractStatusDescription() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, contractStatus).getDescription();
    }

    public void setContractStatus(String codeValue) {
        rxObject.set(contractStatus, _to_String(codeValue));
    }

    public String getContractStatus() {
        return _to_String(rxObject.getCurrentValue(contractStatus));
    }

    public static String getDocumentsLabel() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, documents).getLabel();
    }

    public static String getDocumentsDescription() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, documents).getDescription();
    }

    public int getDocumentsSize() {
        return org.jground.rx.def.apps.commons.Document.wrap(rxObject.getComponents(AttName.documents)).length;
    }

    public org.jground.rx.def.apps.commons.Document[] getDocuments() {
        return org.jground.rx.def.apps.commons.Document.wrap(rxObject.getComponents(AttName.documents));
    }

    public org.jground.rx.def.apps.commons.Document getDocuments(int index) {
        return org.jground.rx.def.apps.commons.Document.wrap(rxObject.getComponents(AttName.documents))[index];
    }

    public org.jground.rx.def.apps.commons.Document createDocuments() {
        return org.jground.rx.def.apps.commons.Document.wrap(rxObject.newComponent(documents));
    }

    public void setDocuments(org.jground.rx.def.apps.commons.Document[] values) {
        rxObject.set(documents, _to_String(documents));
    }

    public void addDocuments(org.jground.rx.def.apps.commons.Document value) {
        rxObject.add(documents, value.getOidString());
    }

    public static String get$CREATORLabel() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, $CREATOR).getLabel();
    }

    public static String get$CREATORDescription() {
        return RXSystem.getInstance().getRxService().getRXAttribute(moid, $CREATOR).getDescription();
    }

    public void set$CREATOR(String string) {
        rxObject.set($CREATOR, _to_String(string));
    }

    public String get$CREATOR() {
        return _to_String(rxObject.getCurrentValue($CREATOR));
    }

}
